<%@ page language="java" pageEncoding="utf-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<div class="navbar navbar-inverse navbar-fixed-top">
	<div class="container">
		<div class="navbar-header">
			<a class="navbar-brand hidden-sm"
				href="${pageContext.request.contextPath }/">KisChang博客</a>
		</div>
		<div class="navbar-collapse collapse" role="navigation">
			<ul class="nav navbar-nav">
				<s:iterator value="menulist">
					<s:if test="childs.size() == 0">
						<li><a href="${pageContext.request.contextPath }/view?mid=<s:property value="id" />"
							target="_self"><s:property value="name" /></a></li>
					</s:if>
					<s:else>
						<li class="dropdown"><a href="javascript:void(0)"
							class="dropdown-toggle" data-toggle="dropdown"><s:property
									value="name" /><b class="caret"></b></a>
							<ul class="dropdown-menu">
								<li><a
									href="${pageContext.request.contextPath }/view?mid=<s:property value="id" />"
									target="_self"><s:property value="name" /></a></li>
								<s:iterator value="childs">
									<li><a
										href="${pageContext.request.contextPath }/view?mid=<s:property value="id" />"
										target="_self"><s:property value="name" /></a></li>
								</s:iterator>
							</ul></li>
					</s:else>
				</s:iterator>
				<c:if test="${user!=null }">
				<li><a href="${pageContext.request.contextPath }/topic/post_view" target="_self">发帖</a></li>
				</c:if>
			</ul>
			<c:if test="${user==null }">
				<ul id="usernode" class="nav navbar-nav navbar-right hidden-sm">
				</ul>
				<script type="text/javascript">
					var usernode = document.getElementById("usernode");
					$
							.post(
									"${pageContext.request.contextPath }/user/login_bycookie",
									function(data) {
										if (data.stat == 1) {//登陆失败
											$(
													"<li><a href='${pageContext.request.contextPath }/user/login_view' target='_self'>登陆</a></li>")
													.appendTo(usernode);
											$(
													"<li><a href='${pageContext.request.contextPath }/user/reg_view' target='_self'>注册</a></li>")
													.appendTo(usernode);
										} else {
											$(
													"<li class='dropdown'><a href='javascript:void(0)'"
															+ "class='dropdown-toggle' data-toggle='dropdown'>欢迎您："
															+ data.msg
															+ "<b class='caret'></b></a>"
															+ "<ul class='dropdown-menu'>"
															+ "<li><a href='${pageContext.request.contextPath }/user/quit' target='_self'>注销</a></li>"
															+ "</ul></li>")
													.appendTo(usernode);
										}
									});
				</script>
			</c:if>
			<c:if test="${user!=null }">
				<ul class="nav navbar-nav navbar-right hidden-sm">
					<li class="dropdown"><a href="javascript:void(0)"
						class="dropdown-toggle" data-toggle="dropdown">欢迎您：${user.nickname }<b
							class="caret"></b></a>
						<ul class="dropdown-menu">
							<li><a href="${pageContext.request.contextPath }/user/quit" target="_self">注销</a></li>
						</ul></li>
				</ul>
			</c:if>
		</div>
	</div>
</div>